<template>
	<div class="CreateUser_tab1">
	     <transition enter-active-class="animated bounceInRight">
			     	<div class="CreateUser_tab_div" v-show="CreateUser_tab_div_show" >
                             <transition enter-active-class="animated bounceInLeft">
                                 
                                  <!-- 表单部分 -->
                             	 <form class="CreateUser_tab_div2" v-show="CreateUser_tab_div_show2">  
                             	        <div class="text2">
											 <h1>注册须知</h1>
											 <div class="carefurl">
												  <p>1.本小站目前正在装修中。</p>
											      <p>2.所有商品均未开放购买。</p>
												  <p>3.图片均来源于其他网络。</p>
												  <p>4.小站仅作学习交流使用。</p>
												  <p>5.注册视为同意以上条款。</p>
											 </div>
											
										 </div>
                             	      
                             	 	  
										 <!-- 填写注册信息部分 -->
                                        <div class="test1">
											 <h1 class="test1_h1">账号注册 <i class="iconfont icon-queshudengji1"></i></h1>
											 <!-- 填写用户名 -->
											 <div class="Create_userName">
                                                  <span class="Create_userName_span"> UserName </span>
												  <input type="text" class="Create_userName_input" placeholder="请创建用户名" v-model="CreateUser" maxlength="10">
											 </div>

											 <!-- 填写密码 -->
											 <div class="Create_userName">
                                                  <span class="Create_userName_span"> PassWord </span>
												  <input type="password" class="Create_userName_input" placeholder="请创建密码" v-model="CreatePass" maxlength="16">
											 </div>
											 <!-- 再次填写密码 -->
											 <div class="Create_userName">
                                                  <span class="Create_userName_span"> PassWord </span>
												  <input type="password" class="Create_userName_input" placeholder="请再次确认您的密码" v-model="CreatePass2" maxlength="16">
											 </div>

											 <!-- 确认提交按钮 -->
											 <button class="Create_userName_submit" @click="check_user">确认提交</button>
											 <!-- 去登陆 -->
											 <div class="hasUser">
												 已有账号？<router-link to="/login" class="tologin">前去登录</router-link>
											 </div>
										</div>
                             	 </form>
                             </transition>
				  	         
				  </div>
	     </transition>
		  
	</div>
</template>

<script>
import axios from 'axios'
	export default {
		data() {
			return {
                    CreateUser_tab_div_show:false,
					CreateUser_tab_div_show2:false,
					pancle_show: true,
					CreateUser:'',
					CreatePass:'',
					CreatePass2:'',
					createInfo:''

			}
		},
		methods: {
              Createshow: function() {
              	  setTimeout(() =>{
              	  	this.CreateUser_tab_div_show= true
              	  },300)
                   }

                   ,
                    Createshow2: function() {
              	  	setTimeout( () =>{
                          this.CreateUser_tab_div_show2 =true
              	  	},1000)
              	  	
					},
					 
                    Createshow3: function() {
              	  	setTimeout( () =>{
                          this.pancle_show =true
              	  	},2500)
              	  	
              	  },
					check_user: function() {
						// 定义正则表达式过滤
						var regx = /[\u4E00-\u9FA5]/ig;
						var regx2 = /[<>./!@#$%^&*()+_":;',.`~]/ig; 
						var check_usn = regx.test(this.CreateUser);
						var check_pas = regx2.test(this.CreatePass);
						var check_usn2 = regx2.test(this.CreateUser);
							if(this.CreateUser==''||this.CreatePass==''){
									   alert('请填写用户名或密码!');
									   return
							}else if(check_usn2||check_pas){
								   alert('用户名或密码不能含有特殊符号!');
								   return
							}
							else{
									if(this.CreatePass!=this.CreatePass2) {
											alert('两次密码输入需一致!');
											return
											
									}else{
											this.create();
											
									}
							}
					},

					create:function(){
						  axios.post('/createUser',{							   
									username:this.CreateUser,
									password:this.CreatePass			
						  }).then( (response) => {
								 this.createInfo = response.data;
								 alert(this.createInfo);
								 this.$router.replace('/login');																 
						  })
					}
		},
		mounted:function() {
                 this.Createshow();
				 this.Createshow2();
				 
		},
		beforeDestroy:function() {
               
		}
	}
</script>

<style>
	 .CreateUser_tab1{ 	
	 	width: 100%;
	 	height: 1000px;
	 	z-index: 100;
	 	overflow: hidden;
		 background-image: url(../../../static/img/027170342.jpg);
	 	background-position: center;
		 background-size: cover;	 
	 }
	 .CreateUser_tab_div{
	 	width: 800px;
	 	height: 600px;
	 	background-color: rgba(0,0,0,0.8);
	 	margin:50px auto;
	 	border-radius: 10px;	 
	 }

	

	 .CreateUser_tab_div2{
		position: relative;
		top: 15px;
	 	height: 540px;
	 	width: 730px;
	 	padding-top:30px;
	 	margin:0 auto;
	 	background-color: #f4f1e9;
	 	text-align: center;
	 	color: #333;
	 	box-shadow: 0 0 10px #9e9e9e;
	 	border-radius: 10px;	   
	 }

	 
	  /*信息*/
	 .text2{
	 	width: 300px;
	 	height: 500px;
	 	border-right:1px solid #9e9e9e; 
	 	float: left;
	 }
	.text2 h1{
		text-align: center;
		margin-top: 70px;
		/* font-size: 20px; */
		font-family: 'SimHei';

	}
	.carefurl p{
		text-align: center;
		line-height: 40px;
		font-size: 10px;
		font-family: 'SimHei'

	}

	.carefurl{
		margin: 20px auto;
		width: 80%;
		height: 100%;

	}
	.test1{
		margin-top: 40px;
		 width: 400px;
		 height: 300px;
		 background-color: #f4f1e9;
		 float:right;
		 box-sizing: border-box;
		 display: flex;
		 align-items: center;
		 justify-content: space-around;
		 flex-direction: column;
	}

	.test1_h1{
		text-align: center;
		
		color: #333;
		font-size: 20px;
		/* font-style: italic; */
        font-weight: bold;
		font-family:'SimHei';
	}

    .test1_h1 i{
        font-size: 30px;
    }
	.Create_userName{
		 width: 280px;
		 height: 30px;
		 border:2px solid #9e9e9e;
		 border-radius:10px;
		
		 position: relative;
	}
	.Create_userName_span{
		 text-align: center;
		 line-height: 30px;
		 float: left;
		 width: 90px;
		 height: 30px;
		 border-top-right-radius: 5px;
		 border-bottom-right-radius: 5px;
		  border-radius:7px;
		 background: #a2ccad;
		 color: rgb(248, 245, 245);
		 border-right: 1px solid #9e9e9e;
		 position: relative;
		 font-family: 'SimHei'
	}
	.Create_userName_input{
		 width: 175px;
		 height: 28px;
		 background-color: #f4f1e9;
		 border: none;
		 outline: none;
		 left: 100px;
		  position: absolute;
		  font-size: 15px;
		  font-family: 'SimHei'
	}

	.Create_userName_submit{
		 width: 280px;
		 height: 35px;
		 border: none;
		 outline: none;		 
		 color: white;
		 background: rgb(116, 151, 161);
		 cursor: pointer;
		 border: 2px solid rgb(150, 149, 149);
		 border-radius: 5px;
		 font-size: 15px;
		 font-family: 'SimHei';	
	}
	.Create_userName_submit:hover{
		 background: rgb(32, 204, 152);
		 border: 2px solid rgb(39, 179, 114);
	}

	.hasUser{
		width: 260px;
		height: 20px;
		color: #333;
		text-align: right;
		font-size: 12px;
	}

	.tologin{
        color: rgb(65, 59, 59);
	}
</style>